<template>
	<view class="store_list_com">
		<u-gap height="8"></u-gap>
		<view class="body">
			<view class="title">
				<view v-if="modelTitle" class="title_left">
					<text class="main">{{ modelTitle }}</text>
					<text class="minor"></text>
				</view>
				<view class="title_right">
					<text></text>
					<!-- <u-icon name="arrow-right" color="#777" size="20"></u-icon> -->
				</view>
			</view>
			<view class="contes">
				<view v-if="num === 1 || num === 2" class="flex-end-grid">
					<template v-if="num === 1">
						<view v-for="item in value" :key="item.id" class="item item-1" @click="itemTo(item)">
							<view class="store__container">
								<u-image
									mode="aspectFit"
									width="156rpx"
									height="104rpx"
									:src="item.logoUrl"
								/>
							</view>

							<view class="grid-text u-line-1">{{ item.brandName }}</view>
						</view>
						<!-- <u-grid-item v-for="item in value" :key="item.id" style="height: 100%;" @click="itemTo(item)">
							<u-image
								mode="widthFix"
								width="200rpx"
								:src="item.brandPicUrl"
								:border-radius="16"
							></u-image>
							<view class="grid-text u-line-1">{{ item.brandName }}</view>
						</u-grid-item> -->
					</template>
					
					<template v-else>
						<view v-for="item in value" :key="item.id" class="item item-2" @click="itemTo(item)">
							<view class="store__container-1">
								<u-image
									mode="aspectFit"
									width="108rpx"
									height="72rpx"
									:src="item.logoUrl"
									style="margin: 0 auto"
								/>
							</view>

							<view class="grid-text u-line-1">{{ item.brandName }}</view>
						</view>
						<!-- <u-grid-item v-for="item in value" :key="item.id" style="height: 100%;" @click="itemTo(item)">
							<u-image
								mode="widthFix"
								width="100rpx"
								:src="item.brandPicUrl"
								:border-radius="16"
							></u-image>
							<view class="grid-text u-line-1">{{ item.brandName }}</view>
						</u-grid-item> -->
					</template>
				</view>

				<view v-else class="scroll-view">
					<view
						v-for="item in value"
						:key="item.id"
						class="item"
						@click="itemTo(item)"
					>
						<u-image
							mode="widthFix"
							width="100rpx"
							:src="item.logoUrl"
							:border-radius="16"
							style="margin: 0 auto"
						>
						</u-image>
						<view class="grid-text u-line-1">{{ item.brandName }}</view>
					</view>
				</view>
			</view>
		</view>
		<u-gap height="8"></u-gap>
	</view>
</template>

<script>
export default {
	props: {
		value: {
			type: Array,
			default: () => []
		},
		
		num: {
			type: [String, Number],
			default: 1
		},

		modelTitle: {
			type: [String, Number],
			default: ''
		},

		modelType: {
			type: [String, Number],
			default: ''
		}
	},
	data() {
		return {}
	},
	
	methods: {
		itemTo(row) {
			const data = {
				...row,
				modelType: this.modelType
			}

			uni.reLaunch({
				url: '/pages/sort/index?brandId=' + row.brandId + '&keyword=' + row.brandName
			})

			// this.$store.commit('VIEW_SWITCH', data)
			// uni.navigateTo({
			// 	url: '/pages/index/store/index?domainPrefix=' + row.domainPrefix
			// })
		}
	}
}
</script>

<style lang="scss" scoped>
.store_list_com {
	margin: 0 24rpx;
	.body {
		background-color: #fff;
		border-radius: 16rpx;
		.title {
			padding: 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.main {
				font-size: 32rpx;
			}
			.minor {
				font-size: 26rpx;
				color: #de3d2b;
				display: inline-block;
				margin-left: 15rpx;
			}
			.title_right {
				font-size: 24rpx;
				color: #777;
			}
		}
		.contes {
			padding: 20rpx;
			padding-top: 0;
			.grid-text {
				// width: 120rpx;
				text-align: center;
				margin-top: 16rpx;
			}
		}
	}
}

.flex-end-grid {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;

	.item {
		width: 33.3333%;
		padding: 0 8px;

		text-align: center;
		// margin-right: 18rpx;
		margin-bottom: 18rpx;
	}

	&.item-1 {
		
		&:nth-of-type(3n + 3) {
			margin-right: 0;
		}
	}

	.item-2 {
		width: 20%;
		&:nth-of-type(5n + 5) {
			margin-right: 0;
		}
	}
  // .u-grid {
  //   align-items:flex-end;
  // }
}

.scroll-view {
	overflow: auto;
	white-space: nowrap;

	.item {
		display: inline-block;
		// margin-left: 20rpx;
		margin-right: 32rpx;
		
		&:last-child {
			margin-right: 0;
		}
	}
}

.store__container {
	width: 180rpx;
	height: 124rpx;
	padding: 10rpx 12rpx;
}

.store__container-1 {
	width: 116rpx;
	height: 80rpx;
	padding: 4px;
}
</style>
